import mne
import matplotlib.pyplot as plt
from sklearn import preprocessing
import numpy as np
from keras.utils.np_utils import to_categorical
from sklearn.model_selection import train_test_split

"""
    Physionet MI-EEG Dataset
    64 channels EEG，160hz freq, 4 seconds MI-task
    14 runs for each of the 109 subjects
        runs [1, 2] is baseline
        others with marker
            T0   : rest, 
            T1/T2: left/right fist in runs [3, 4, 7, 8, 11, 12]
                   both fists/feet in runs [5, 6, 9, 10, 13, 14]

"""
import os
import pandas as pd
data_path = "/dataset/original/"
save_path = "/dataset/109subjects/fiest_LR/"


os.mkdir(save_path)
train_data_raw = np.load(os.path.join(data_path, "train_data_total.npy")).transpose(0, 2, 1)
test_data_raw = np.load(os.path.join(data_path, "test_data_total.npy")).transpose(0, 2, 1)
train_lable_raw = np.load(os.path.join(data_path, "train_lable_total.npy"))
test_lable_raw = np.load(os.path.join(data_path, "test_lable_total.npy"))
for i in train_lable_raw:
    if train_lable_raw[:,i] == 0





    np.save(os.path.join(save_path, "train_data_total" ),  train_data_total, allow_pickle=True)
    np.save(os.path.join(save_path, "test_data_total" ),   test_data_total, allow_pickle=True)
    np.save(os.path.join(save_path, "train_lable_total" ), train_label_total, allow_pickle=True)
    np.save(os.path.join(save_path, "test_lable_total" ),  test_label_total, allow_pickle=True)
    for r in res:
        print(r.shape)